﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
using Simple.Services.System.QHSEViolationCategory.Models;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 安全观察与沟通管理
/// </summary>
[Route("QHSEViolationObserver/[action]")]
[ApiController]
public class QHSEViolationObserverController : ControllerBase
{
    private readonly QHSEViolationObserverService _violationObserverService;

    public QHSEViolationObserverController(QHSEViolationObserverService violationObserverService)
    {
        _violationObserverService = violationObserverService;
    }
    /// <summary>
    /// 安全观察与沟通列表
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEViolationObserverModel> menus = await _violationObserverService.GetAsync();
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> List1()
    {
        List<QHSEViolationObserverModel> menus = await _violationObserverService.GetAsync();
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 安全观察与沟通第一级列表
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> ObserverList()
    {
        List<QHSEViolationObserverModel> menus = await _violationObserverService.GetObserverAsync();
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 安全观察与沟通第二级列表
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Observer2List([FromBody]QHSEViolationObserverModel item)
    {
        List<QHSEViolationObserverModel> menus = await _violationObserverService.GetObserver2Async(item.Item1);
        return AppResult.Status200OK(data: menus);
    }
}
